/*
 * @Author: yushuang
 * @Date: 2024-12-05 09:48:58
 * @LastEditors: yushuang
 * @LastEditTime: 2024-12-17 17:49:51
 * @Description:
 */
import { useGet, usePost } from '@/composables/api';
export interface LoginParams {
  username: string;
  password: string;
  type?: 'account';
}

export interface LoginMobileParams {
  mobile: string;
  code: string;
  type: 'mobile';
}

export interface LoginResultModel {
  token: string;
}

export function loginApi(params: LoginParams | LoginMobileParams) {
  return usePost<LoginResultModel, LoginParams | LoginMobileParams>('/login', params, {
    // 设置为false的时候不会携带token
    token: false,
    // 开发模式下使用自定义的接口
    customDev: true,
    // 是否开启全局请求loading
    loading: true
  });
}

export function logoutApi() {
  return useGet('/logout');
}
